package org.grow.secure.exception;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author: xwg
 * @CreateDate: 2022/5/24
 */

@RestControllerAdvice
public class ExceptionBridge {

    @ExceptionHandler(BillStateException.class)
    public ResponseEntity<String> catchBillStateException(BillStateException e) {
        return new ResponseEntity<>(e.getMessage(), null, e.getCode());
    }

    @ExceptionHandler(CommonException.class)
    public ResponseEntity<String> catchCommonException(CommonException e) {
        return new ResponseEntity<>(e.getMessage(), null, e.getCode());
    }

}
